<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:t="http://myfaces.apache.org/tomahawk">

<f:view>
	<f:loadBundle var="messages" basename="messages" />

	<head>
	<title>#{messages['categoriaForm.title']}</title>
	<style type="text/css">
.jscalendar-DB-div-style {
	position: absolute;
	margin-top: -69px;
	margin-left: -408px;
}
</style>
	</head>

	<h:messages errorClass="error" layout="table" style="width: 100%" />

	<p>Por favor preencha as informacoes de categoria abaixo:</p><br/>

	<h:form id="categoriaForm">
		<h:inputHidden value="#{categoriaForm.categoria.id}">
			<f:convertNumber />
		</h:inputHidden>
		<h:panelGrid columns="3" styleClass="detail" columnClasses="label">

			<h:outputLabel for="name" value="#{messages['categoria.categoria']}" />

			<h:inputText value="#{categoriaForm.categoria.categoria}" id="name"
				required="true">
				<f:validateLength minimum="5" maximum="20" />
			</h:inputText>
			
			<h:message for="name" styleClass="errorMessage" />

			<h:outputLabel for="description"
				value="#{messages['categoria.descricao']}" />

			<h:inputText value="#{categoriaForm.categoria.descricao}"
				id="description" required="true">
				<f:validateLength minimum="5" maximum="20" />
			</h:inputText>
			
			<h:message for="description" styleClass="errorMessage" />

			<h:panelGroup>
				<h:commandButton value="Save" action="#{categoriaForm.save}"
					id="save" styleClass="button" />
					
				<c:if test="${not empty categoriaForm.id}">
					<h:commandButton onclick="return confirm('Confirma Exclusao da Categoria?');"
					value="Delete" action="#{categoriaForm.delete}"	id="delete" styleClass="button" />
				</c:if>
								
				<h:commandButton value="Cancel" action="cancel" immediate="true"
					id="cancel" styleClass="button" />
			</h:panelGroup>
			<h:inputHidden value="" />
		</h:panelGrid>
	</h:form>

	<script type="text/javascript">
	Form.focusFirstElement(document.forms['categoriaForm']);
</script>

</f:view>
</html>